const pageContent={
  productImg:[
    "https://img.alicdn.com/imgextra/i1/4161056916/O1CN01Qc0zLj20xZp3ZgtVJ_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i3/4161056916/O1CN01UxPLTP20xZp1EmLwW_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i3/4161056916/O1CN01vLyDS620xZouhQ1fF_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i4/4161056916/O1CN01jkoKpO20xZp0umiNw_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i1/4161056916/O1CN01Qc0zLj20xZp3ZgtVJ_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i3/4161056916/O1CN01UxPLTP20xZp1EmLwW_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i3/4161056916/O1CN01vLyDS620xZouhQ1fF_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i4/4161056916/O1CN01jkoKpO20xZp0umiNw_!!4161056916.png",
     "https://img.alicdn.com/imgextra/i1/4161056916/O1CN01Qc0zLj20xZp3ZgtVJ_!!4161056916.png",
    "https://img.alicdn.com/imgextra/i3/4161056916/O1CN01UxPLTP20xZp1EmLwW_!!4161056916.png",
  ],
  productId:[
    "574576989687",
    "527036337530",
    "527050980299",
    "527036505839",
    "527048328080",
    "527049104768",
    "526988691534",
    "527034325527",
    "618199527842",
    "527037589068",
    "527027746637",
    "527048692450"
  ]
}
Page({
  data: {
    ...pageContent,
    collectflag:[],
    flag:false,
		btnnum:12,
		isShowTaskRes:false,
		hotLink:[
			{"lwhtl":[160,228,275,105],"nllink":"1"},
			{"lwhtl":[160,228,277,288],"nllink":"1"},
			{"lwhtl":[160,228,271,483],"nllink":"1"},
			{"lwhtl":[160,228,540,106],"nllink":"1"},
			{"lwhtl":[160,228,538,301],"nllink":"1"},
			{"lwhtl":[160,228,541,487],"nllink":"1"},
			{"lwhtl":[160,228,805,104],"nllink":"1"},
			{"lwhtl":[160,228,795,299],"nllink":"1"},
			{"lwhtl":[160,228,801,480],"nllink":"1"},
			{"lwhtl":[160,228,1056,101],"nllink":"1"},
			{"lwhtl":[160,228,1056,286],"nllink":"1"},
			{"lwhtl":[160,228,1054,487],"nllink":"1"}
		]
	},
	
	//打开商详
	shopDetail(e){
		my.tb.openDetail ({
      itemId: this.data.productId[e.target.dataset.idx],
      success: (res) => {
        
      },
      fail: (res) => {
        
      },
		});	
	},

  allcol(){
		
    this.data.productId.forEach((e,i) => {

			my.tb.collectGoods({
				id: parseInt(e),
				success: (res) => {
					// this.setData({
					//   [`collectflag[${i}]`]: true,
					//   flag:true
					// })
				}
			})

		});

		my.authorize({
			scopes: 'scope.userInfo',
			success: () => {
				my.getAuthUserInfo({
					success: (userInfo) => {
						//收藏好物接口
						getApp().cloud.function.invoke('client',{nick_nam:userInfo.nickName},"collect").then(res => {
							console.log('当前用户信息===》',res); 

							if(res.code != 0){
								my.alert({
									content: res.msg
								})

								return;
							}

							this.setData({
								isShowTaskRes:true,
								flag:true
							})

							
						})
					}
				})
			}
		})

		

		

  },
  onLoad() {
		
		let lin = this.data.hotLink

		lin.map((v,i) => {
			
			v.w = v.lwhtl[0]
			v.h = v.lwhtl[1]
			v.t = v.lwhtl[2]
			v.l = v.lwhtl[3]
		})

		this.setData({
			hotLink:lin
		})

    
  },
});
